import { FOLLOW_STATUS } from '@/enum/dynamic.enum';
import { GET, POST } from '@/libs';
import { UserInfo } from '@/store/modules/user.module';

export const getUserInfo = () => {
  return GET<PersonalMessageDto>({
    url: '/user/getUserInfo'
  });
};

export const watchUser = (targetUserId: number) => {
  return POST({
    url: '/user/watchUser',
    data: {
      targetUserId
    }
  });
};

export type PersonalMessageDto = {
  /**
   * 他人的用户id
   */
  id: number;

  /**
   * 他人用户头像
   */
  avatarUrl: string;

  /**
   * 他人昵称
   */
  nickName: string;

  /**
   * 他人所有动态获赞数
   */
  dynamicLoveCount: number;

  /**
   * 他人关注的人数量
   */
  followCount: number;

  /**
   * 他人粉丝数
   */
  fansCount: number;

  /**
   * 是否被关注
   */
  followStatus: FOLLOW_STATUS;
};

export const getPersonalMessage = (userId: number) => {
  return GET<PersonalMessageDto>({
    url: '/user/getPersonalMessage',
    params: {
      id: userId
    }
  });
};

export const gerUserinfoByUserId = (userId: number) => {
  return GET<UserInfo>({
    url: '/user/gerUserinfoByUserId',
    params: {
      userId: userId
    }
  });
};

export type FollowDto = {
  id: number;

  userId: number;

  targetUserId: number;

  status: FOLLOW_STATUS;

  /**
   * 用户信息
   */
  targetUserInfo: UserInfo;
};

export const getWathUser = () => {
  return GET<FollowDto[]>({
    url: '/user/getWathUser'
  });
};

export const getFans = () => {
  return GET<FollowDto[]>({
    url: '/user/getFans'
  });
};
